/*
 * @lc app=leetcode.cn id=303 lang=csharp
 *
 * [303] 区域和检索 - 数组不可变
 */

// @lc code=start
public class NumArray {
    
        private int[] _sums;
        public NumArray(int[] nums) {
            var length = nums.Length;
            _sums = new int[length + 1];
            for(int i = 0; i < length; ++i)
            {
                _sums[i + 1] = _sums[i] + nums[i];
            }
        }
        
        public int SumRange(int left, int right) {
            return _sums[right + 1] - _sums[left];
        }
}

/**
 * Your NumArray object will be instantiated and called as such:
 * NumArray obj = new NumArray(nums);
 * int param_1 = obj.SumRange(left,right);
 */
// @lc code=end

